﻿using Uber.Core;

namespace Uber.Service
{
    using Core.Model;
    using Core.Repository;
    using Core.Service;

    public class GoldBuys : IGoldBuys
    {
        private readonly IGoldBuyRepo repo;

        public GoldBuys(IGoldBuyRepo repo)
        {
            this.repo = repo;
        }

        public bool Insert(GoldBuy o)
        {
            return repo.Insert(o) == The.Success;
        }

        public bool Exists(string tid)
        {
            return repo.Count(tid) > 0;
        }

        public IPageable<GoldBuy> GetPage(int page, int pageSize)
        {
            return new Pageable<GoldBuy>
            {
                PageIndex = page,
                Page = repo.GetPage(page, pageSize),
                PageCount = ServiceUtils.GetPageCount(pageSize, repo.Count())
            };
        }
    }
}